package exam;

import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;
import java.util.TreeSet;
import java.util.stream.Collectors;

import org.junit.Test;

class FlightTicketInfo {

    private String orderNumber;

    private String userName;

    private String age;

    public FlightTicketInfo(String orderNumber, String userName, String age) {
        this.orderNumber = orderNumber;
        this.userName = userName;
        this.age = age;
    }

    @Override
    public String toString() {
        return "FlightTicketInfo{" +
                "orderNumber='" + orderNumber + '\'' +
                ", userName='" + userName + '\'' +
                ", age='" + age + '\'' +
                '}';
    }

    public String getOrderNumber() {
        return orderNumber;
    }

    public String getUserName() {
        return userName;
    }

    public String getAge() {
        return age;
    } 
    public static void main(String[] args) {
	   List<FlightTicketInfo> infoList = new ArrayList<>();
       infoList.add(new FlightTicketInfo("11111", "xiaoming", "22"));
       infoList.add(new FlightTicketInfo("22222", "xiaoming", "22"));
       infoList.add(new FlightTicketInfo("33333", "xiaoming", "23"));
       infoList.add(new FlightTicketInfo("11111", "xiaoming", "22"));
       List<String> endList = infoList.stream().map(list -> list.getUserName())
               .collect(Collectors.collectingAndThen(Collectors.toCollection(() -> new TreeSet<>(Comparator.comparing(f -> f))), ArrayList::new));
       System.out.println(endList);
	} 
}